<div id="poi_browser_container">
<form id="choose_poi_form" action="<?php echo $this->getUrl(NULL, "poi-list") ?>" method="post">
    <input type="hidden" id="callback" name="callback" value="<?php echo $this->options['callback'] ?>"/>
    <?php foreach($this->ignores as $ignore):?>
    <input type="hidden" name="ignores[]" value="<?php echo $ignore ?>"/>
    <?php endforeach;?>
    <table class="search" cellpadding="4px;">
        <tr>
            <td><?php echo Kd_Localize_Helper::__('foundation.label.industry') ?></td>
            <td>
                <?php 
                    $selectIndustry = new Stable_Html_Form_Industry();
                    $selectIndustry->setId('poi_industry')->setName('filter[industry]');
                    if($this->filter && isset($this->filter['industry'])){
                        $selectIndustry->setValue($this->filter['industry']);
                    }
                    echo $selectIndustry->toHtml()
                ?>
            </td>
            <td><?php echo Kd_Localize_Helper::__('share.label.picture') ?></td>
            <td>
                <?php 
                    $pictureSelect = new Kd_Html_Form_Select();
                    $pictureSelect->setId('poi_picture')
                                  ->setName('filter[picture]')
                                  ->setOption('--', '');
                    $pictureSelect->setOption(Kd_Localize_Helper::__('foundation.label.has_picture'), '1');
                    $pictureSelect->setOption(Kd_Localize_Helper::__('foundation.label.no_picture'), '2');
                    echo $pictureSelect->toHtml();
                ?>
            </td>
            <td rowspan="2">
                <button type="submit"><?php echo Kd_Localize_Helper::__('share.button.search')?></button>
            </td>
        </tr>
        <tr>
            <td><?php echo Kd_Localize_Helper::__('foundation.label.road') ?></td>
            <td>
                <?php
                    $selectRoad = new Stable_Html_Form_Road();
                    $selectRoad->setId('poi_road')->setName('filter[road]');
                    if($this->filter && isset($this->filter['road'])){
                        $selectRoad->setValue($this->filter['road']);
                    }
                    echo $selectRoad->toHtml()
                ?>
            </td>
        </tr>
    </table>
    <div id="grid_container"></div>
</form>
</div>
<script language="javascript" type="text/javascript">
    $('#choose_poi_form').submit(function(){
        $('#choose_poi_form').ajaxSubmit({
            success:function(responseText, statusText, xhr, $form){
                $('#grid_container').html(responseText);
            }
        });
        return false;
    });

    function chooseMulti(){
        $('#choose_poi_grid :checked').each(function(){
            returnChoose($(this));
        });
    }

    function returnChoose(el){
        var callback = <?php echo $this->options['callback'] ?>;
        var data = {};
        var tr = $($(el).parent().parent());
        data.id = tr.attr('id').substring(3);
        data.text = tr.find('td[field="shopname"]').text();
        callback(data);
        $('#choose_poi_form').append('<input type="hidden" name="ignores[]" value="' + data.id + '"');
        $(el).parent().parent().remove();
    }

    function statRoadSearch(roadId){
        poi_road_road.setValue(roadId);
        $('#choose_poi_form').submit();
    }

    function statIndustrySearch(industryId){
        poi_industry_industry.setValue(industryId);
        $('#choose_poi_form').submit();
    }
    
    $('#poi_browser_container').dialog({
        width:800,
        height:600,
        resizable: false,
        title: '<?php echo $this->title ?>',
        modal: true,
        close: function(event, ui){
            $(this).dialog( "destroy" );
            $('#poi_browser_container').remove();
        }
    });
</script>